package com.admin.education.models;

import com.admin.education.repositories.Identifiable;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;

@Entity
@Table(name = "answers")
@EntityListeners(AuditingEntityListener.class)
@Data
public class Answers  implements Serializable,Identifiable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;
    @Column(name = "answer_description")
    @NotBlank
    @Length(max=1024)
    private String answerDescription;
    @ManyToOne
    @NotNull
    private Questions questions;
    @Column(name="sort")
    @NotNull
    private  int sort;
    @Column(name = "alias")
    @Length(max=32)
    private String alias;
    @Column(name = "right_answer")
    @NotNull
    private boolean rightAnswer;
    @OneToMany
    private List<Comments> comments;
}
